<?php
namespace App\Http\Controllers\Admin;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Session;
use App\Services\MemberService;
use App\Services\OrderService;

class HomeController extends Controller{
	public function index(){
		$username = Session::get('username');

		if($username != ''){
			$member = new MemberService;
			$order = new OrderService;
			$s_dt = date('Y-m-d 00:00:00');
			$e_dt = date('Y-m-d 23:59:59');

			$data['mtcount'] = $member->getMemberCount($s_dt,$e_dt);
			$data['membercount'] = $member->getMemberCount();
			$data['otcount'] = $order->getSaleCount($s_dt,$e_dt);
			$data['ordercount'] = $order->getSaleCount();
			$data['username'] = $username;

			return view('admin.home.home',$data);
		}else{
			return redirect('/admin/login');
		}
	}
}